The number of registered nonprofits in the US was highest in 2017 and has been decreasing since then.
Over 75% 501 c(3) organizations are Public charities in 2019
Number of Private foundations remained constant over years compared to public charity-type nonprofits
The nonprofit sector is heavily impacted by the domestic economic market
\(\textbf{Source:}\) IRS Business Master File 2002, 2012, 2017, 2022
In 2019, public charity-type nonprofits had the most total assets, spend the most, and earned the most revenues among all nonprofit types.
All nonprofits, on average, were profitable in 2019 if calculating profits as the gap between revenue and expense.
Generally, Private foundations were more profitable than public charities, considering private foundations represented a smaller share of all nonprofits than public charities, however, they had smaller gaps between expense and revenues (PF profited 4ish times less than PC) than their size differences (There are 10 times more PC than PF)
\(\textbf{Source:}\) NCCS Core File 2019
Public charity has the most organizations out of NCCS scope.
Regardless of the nonprofit type, the proportion of organizations outside the NCCS scope is small enough that we can neglect them.
Most Public Charities spent less than $100, 000 in 2019
The spending distribution is highly right-skewed
CA-based Private Foundations gained more total revenues than their counterparts in NY, despite the latter has more organizations
Private Foundations that are based in CA and NY exceed than their counterparts in other states on both measures of total expense and total revenue
| 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | |
|---|---|---|---|---|---|---|---|---|---|---|
| Per year | ||||||||||
| Percent of population volunteering | 26.4 | 26.8 | 26.3 | 26.8 | 26.5 | 25.4 | 25.3 | 24.9 | 25.2 | 25.1 |
| Number of volunteers (millions) | 61.8 | 63.4 | 62.8 | 64.3 | 64.5 | 62.6 | 62.8 | 62.6 | 63.9 | 64.4 |
| Hours volunteered (billions) | 8 | 8.1 | 8.1 | 8.5 | 8.5 | 8.3 | 8.7 | 8.5 | 8.7 | 8.8 |
| Average hours per volunteer | 130 | 128 | 129 | 132 | 132 | 133 | 139 | 136 | 136 | 137 |
| Median hours per volunteer | 52 | 52 | 52 | 51 | 50 | 50 | 50 | 52 | – | – |
| Per average day | ||||||||||
| Percent of population volunteering | 6.8 | 7.1 | 6.8 | 6 | 5.8 | 6.1 | 6.4 | 6.4 | 5.6 | 6 |
| Number of volunteers (millions) | 16.2 | 17.1 | 16.6 | 14.6 | 14.3 | 15.1 | 16 | 16.3 | 14.4 | 15.6 |
| Hours per day per volunteer | 2.43 | 2.39 | 2.46 | 2.84 | 2.48 | 2.57 | 2.41 | 2.49 | 2.39 | 2.86 |
| Value of volunteers | ||||||||||
| Population age 16 and over (millions) | 234.4 | 236.3 | 238.3 | 240 | 243.8 | 246.2 | 248.4 | 251.3 | 253.6 | 256 |
| Full-time-equivalent employees (millions) | 4.7 | 4.8 | 4.8 | 5 | 5 | 4.9 | 5.1 | 5 | 5.1 | 5.2 |
| Assigned hourly wages for volunteers | $18.08 | $18.63 | $19.07 | $19.47 | $19.75 | $20.16 | $20.59 | $21.08 | $21.63 | $22.13 |
| Assigned value of volunteer time ($ billions) | $144.70 | $150.70 | $154.10 | $164.80 | $168.30 | $167.20 | $179.20 | $179.00 | $187.40 | $195.00 |
---
title: "Nonprofit Sector In Brief Flex Dashboard"
output:
flexdashboard::flex_dashboard:
logo: Resized_Urban_Logo.png
social: menu
source_code: embed
theme: cerulean
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
message = FALSE,
warning =FALSE)
```
```{r, include=FALSE}
library(flexdashboard)
library(htmlwidgets)
library(DT)
library(httr)
library(tidyverse)
library(stringr)
library(RCurl)
library(reshape2)
library(RColorBrewer)
library(extrafont)
library(knitr)
library(foreign)
library(kableExtra)
library(urbnthemes)
library(grid)
library(gridExtra)
library(rmarkdown)
library(plotly)
library(sf)
library(sp)
library(ggmap)
library(leaflet)
#library(highcharter)
set_urbn_defaults()
```
Summary {.storyboard}
=======================================================================
```{r, echo=F}
Nonprofit_trend <-
read_csv("../Data/Output_Data/Number_nonprofit_trend.csv") %>%
select(!1)
Nonprofit_trend$Year = as.character(Nonprofit_trend$Year)
```
### 501 C(3) Nonprofits in a Decade
```{r}
p_trend <- Nonprofit_trend %>%
ggplot(aes(x = as.factor(Year),
group=1)) +
geom_line(aes(y = `All registered nonprofits`),
color = "#000000") +
geom_point(aes(y = `All registered nonprofits`),
color = "#000000",
size = .8) +
geom_line(aes(y = `501(c)(3) public charities`),
color = "#1696d2") +
geom_point(aes(y = `501(c)(3) public charities`),
color = "#1696d2",
size = .8) +
geom_line(aes(y = `501(c)(3) private foundations`),
color = "#FF9933") +
geom_point(aes(y = `501(c)(3) private foundations`),
color = "#FF9933",
size = .8) +
labs(x = "",
y = "") +
guides(color = guide_legend(title = " ")) +
scale_color_discrete(labels = c("All registered nonprofits",
"501(c)(3) public charities")) +
theme(legend.position="right",
legend.direction = "vertical") +
theme(axis.line.y = element_blank(),
axis.ticks = element_blank()) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 1600000),
breaks = c(0,100000, seq(500000, 1500000, 250000)))
p_trend <- p_trend +
annotate("text",
x = 4.2,
y = 1300000,
label = "All nonprofit",
size = 3.5)
p_trend <- p_trend +
annotate("text",
x = 4.2,
y = 1000000,
label = "Public charity",
size = 3.5)
p_trend <-
p_trend +
annotate("text",
x = 4.2,
y = 150000,
label = "Private foundation",
size = 3.5)
ggplotly(p_trend) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- The number of registered nonprofits in the US was highest in 2017 and has been decreasing since then.
- Over 75% 501 c(3) organizations are Public charities in 2019
- Number of Private foundations remained constant over years compared to public charity-type nonprofits
- The nonprofit sector is heavily impacted by the domestic economic market
$\textbf{Source:}$ IRS Business Master File 2002, 2012, 2017, 2022
### Financial Information by Type
```{r}
Finance <- read_csv("../Data/Output_Data/Nonprofit_finance_2019.csv") %>%
select(!1)
p_fin <- Finance %>%
filter(Type %in% c("PC", "CO", "PF"),
Variable != "Reporting") %>%
ggplot(aes(x = Variable,
y = Value,
fill = Type)) +
geom_col(position = "dodge") +
# geom_text(aes(Variable, Value, label=Value),
# vjust=-.1,
# position = position_dodge(width=1),
# size =3) +
# ylim(NA, 5000) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 5000),
breaks = c(0, 100, 500,
seq(1000, 2000, 1000), 4500)) +
labs(x = "", y = "") +
theme(legend.position="right",
legend.direction = "vertical") +
theme(axis.ticks = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank())
ggplotly(p_fin) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- In 2019, public charity-type nonprofits had the most total assets, spend the most, and earned the most revenues among all nonprofit types.
- All nonprofits, on average, were profitable in 2019 if calculating profits as the gap between revenue and expense.
- Generally, Private foundations were more profitable than public charities, considering private foundations represented a smaller share of all nonprofits than public charities, however, they had smaller gaps between expense and revenues (PF profited 4ish times less than PC) than their size differences (There are 10 times more PC than PF)
$\textbf{Source:}$ NCCS Core File 2019
### Outside NCCS Scope
```{r}
inoutnccs <- read_csv("../Data/Output_Data/outnccs_19.csv") %>% select(!1)
```
```{r}
p_out <- inoutnccs %>%
filter(OUTNCCS == "OUT") %>%
ggplot(aes(x = reorder(factor(type),n),
y= n)) +
geom_bar(stat = "identity",
fill = "skyblue1") +
# geom_text(aes(label = n),
# position= position_dodge(width=1),
# vjust =-.3,
# size=3) +
scale_x_discrete(limits = rev) +
labs(x = "",
y = "") +
theme(axis.ticks = element_blank()) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 3200),
breaks = c(0, 200, seq(1000, 3000, 1000)))
ggplotly(p_out) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- Public charity has the most organizations out of NCCS scope.
- Regardless of the nonprofit type, the proportion of organizations outside the NCCS scope is small enough that we can neglect them.
Public Charity in 2019 {.storyboard}
=======================================================================
### Number of PCs by Expense Level
```{r}
PC_expense_long <- read_csv("../Data/Output_Data/PC2019_by_expense.csv") %>%
select(!1) %>%
mutate(Expense_Group2 = case_when(
`Expense Group` %in% c("a. Under $100,000",
"b. $100,000 to $499,999",
"c. $500,000 to $999,999") ~ "Under 1 million",
`Expense Group` %in% c("d. $1 million to $4.99 million",
"e. $5 million to $9.99 million") ~ "1 million to 10 million",
`Expense Group` %in% c("f. $10 million or more") ~ "10 million or more",
`Expense Group` %in% c("Total Expense") ~ "Total"
)) %>%
pivot_longer(4:7,
values_to = "Value",
names_to = "Financial_Group")
```
```{r}
pc2019 <- read_csv("../Data/core2019pc.csv") %>%
select(!1)
```
```{r}
ggplotly(
pc2019 %>%
mutate(EXPCAT = factor(EXPCAT)) %>%
group_by(EXPCAT) %>%
summarise(n = n()) %>%
ggplot(aes(x = EXPCAT,
y = n)) +
geom_bar(stat = "identity",
fill = "cadetblue2") +
# geom_text(aes(label = n),
# position= position_dodge(width=1),
# hjust = .3, size=3) +
scale_x_discrete(labels = c("Under 100,000", "100,000 - 499,999",
"500,000 - 999,999", "1 - 4.9 million",
"5 - 9.9 million", "10 million or more")) +
# scale_x_discrete(labels = function(type) stringr::str_wrap(type, width=10)) +
# scale_x_discrete(limits = rev) +
# ylim(NA, 250000) +
labs(x = "",
y = "") +
theme(#axis.text.x = element_blank(),
axis.ticks = element_blank(),
axis.line.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
#panel.grid.major.x = element_line(color = "gray60", size = 0.8, linetype = "dashed")
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 210000),
breaks = c(0, 25000, seq(50000, 200000, 50000)))) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- Most Public Charities spent less than $100, 000 in 2019
- The spending distribution is highly right-skewed
### PC Financial Informaiton by by Expense Level
```{r, echo=FALSE}
p_expense <-
PC_expense_long %>%
filter(Financial_Group %in% c("Total Assets", "Total Revenue")) %>%
ggplot(aes(x = reorder(factor(Expense_Group2), Value),
y = Value,
fill = Financial_Group)) +
geom_col(position = "dodge") +
labs(x = NULL,
y = NULL) +
# geom_text(aes(label = Value),
# position= position_dodge(width=1), vjust =-.1, size=3) +
theme(axis.ticks = element_blank()) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 5000),
breaks = c(0, 200, seq(1000, 4000, 1000))) +
theme(legend.position="right",
legend.direction = "vertical")
ggplotly(p_expense) %>%
layout(legend = list(orientation = "h",
x = 0.15,
y = -0.1),
hoverlabel = list(bgcolor = "white"))
```
***
- Organizations that spent more also earned more and had more assets.
- Expenditure is positively related to total assets and total revenue.
### Number of PCs by Category
```{r}
ggplotly(
pc2019 %>%
mutate(NTEEGRP = factor(NTEEGRP)) %>%
group_by(NTEEGRP) %>%
summarise(n = n()) %>%
ggplot(aes(x = reorder(NTEEGRP,n),
y = n)) +
geom_bar(stat = "identity",
fill = "cadetblue2") +
# geom_text(aes(label = n),
# position= position_dodge(width=1),
# hjust = 3,
# size=3) +
# scale_x_discrete(limits = rev) +
labs(x = "",
y = "") +
theme(#axis.text.x = element_blank(),
axis.line = element_blank(),
axis.ticks.y = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(color = "gray60",
size = 0.8,
linetype = "dashed")
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 150000),
breaks = c(0, 10000, seq(25000, 125000, 25000))) +
coord_flip()
) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- Most 501 c(3) public charities could be classified under Human services, other public/social services, and other education groups.
- Higher education and healthcare are the bottom two groups for PCs
### PC Finance Information by Category
```{r}
PC_category <-
read_csv("../Data/Output_Data/PC2019_by_category.csv") %>%
select(!1)
PC_category_long <- PC_category %>%
pivot_longer(4:7,
values_to = "Value",
names_to = "NTEE_Group") %>%
select(Category, NTEE_Group, Value)
p_category <-
PC_category_long %>%
filter(NTEE_Group %in% c("Total Expenses", "Total Revenue")) %>%
ggplot(aes(x = reorder(Category, Value),
y = Value,
fill = NTEE_Group)) +
geom_bar(position = "dodge",
stat = "identity") +
labs(x = NULL,
y = NULL) +
coord_flip() +
# geom_vline(xintercept = seq(0, 3000, 500), linetype="dotted") +
# geom_text(data = PC_category_long %>% mutate(Category = reorder(Category, Value)) %>% #slice(1:2, 7:12, 13:18), aes(label = formatC(round(Value,2), format = 'f', digits =2)),
# position= position_dodge(width=1), hjust =-.1, size=3) +
theme( panel.grid.major.x = element_line(color = "gray60",
size = 0.8,
linetype = "dashed") ) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 2600),
breaks = c(0,100, 250, seq(500, 2500, 500))) +
theme(
axis.line.x = element_blank(),
panel.grid.major.y = element_blank(),
# panel.grid.minor.y = element_blank()
) +
theme(legend.position="right",
legend.direction = "vertical")
# scale_x_discrete(limits = rev)
ggplotly(p_category) %>%
layout(legend = list(orientation = "h",
x = 0.15,
y = -0.1),
hoverlabel = list(bgcolor = "white"))
```
***
- Hospitals and healthcare-related PCs had the smallest number in 2019 but spent and earned
significantly more than PCs of other groups
- Both PC spending and revenue bars are highly stratified
Private Foundation in 2019 {.storyboard}
=======================================================================
### Number of PFs by State
```{r, include=F}
pf19_state <- read_csv("../Data/Output_Data/PF2019_by_state.csv") %>%
select(!1)
```
```{r}
p_state_size <-
pf19_state %>%
mutate(STATE = factor(STATE)) %>%
mutate(STATE = reorder(STATE, Number)) %>%
arrange(-Number) %>%
head(20) %>%
ggplot(aes(y = Number,
x = STATE))+
geom_bar(stat="identity",
width = .8,
fill="palegreen3") + #lightgreen
labs(x = "", y = "") +
theme(#axis.text.x = element_blank(),
# axis.ticks.x = element_blank(),
axis.line.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(color = "gray60",
size = 0.8,
linetype = "dashed")
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 9000),
breaks = c(0, 1000, seq(2000, 8000, 1000))) +
coord_flip()
# geom_text(aes(label = Number),
# position= position_dodge(width=1), hjust =-.2, size=3)
#p_state_size
ggplotly(p_state_size) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- NY, CA, FL, TX, and PA have the most private foundation-type nonprofits
- Generally, larger states also have more PF nonprofits.
### PF Finance Information by State
```{r}
ggplotly(
pf19_state %>%
mutate(STATE = factor(STATE)) %>%
mutate(STATE = reorder(STATE, Number)) %>%
arrange(-Number) %>%
head(5) %>%
select(!c(2,4)) %>%
pivot_longer(2:3,
values_to = "Amount",
names_to = "Finance") %>%
ggplot(aes(y = Amount,
x = STATE,
fill = Finance))+
geom_bar(position = "dodge",
stat="identity",
width = .9) +
labs(x = "", y = "") +
theme(#axis.text.y = element_blank(),
axis.ticks.x = element_blank(),
# axis.ticks.y = element_blank(),
# panel.grid.major.y = element_blank(),
# panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank()
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 16),
breaks = c(0,2,5,10,15)) +
# geom_text(aes(label = Amount),
# position= position_dodge(width=1), vjust =-.1, size=3) +
scale_x_discrete(limits = rev) +
theme(legend.position="right",
legend.direction = "vertical")
) %>%
layout(legend = list(orientation = "h",
x = 0.12,
y = -0.15),
hoverlabel = list(bgcolor = "white"))
```
***
- CA-based Private Foundations gained more total revenues than their counterparts in NY, despite the latter has more organizations
- Private Foundations that are based in CA and NY exceed than their counterparts in other states on both measures of total expense and total revenue
### Number of PFs by Category
```{r}
pf19_category <-
read_csv("../Data/Output_Data/PF2019_by_category.csv") %>%
select(!1)
ggplotly(
pf19_category %>%
mutate(NTEEGRP = factor(NTEEGRP)) %>%
mutate(NTEEGRP = reorder(NTEEGRP,
Number)) %>%
# arrange(-Number) %>%
# head(25) %>%
ggplot(aes(y = Number, x = NTEEGRP))+
geom_bar(stat="identity",
width = .9,
fill ="palegreen3") +
labs(x = "", y = "") +
theme(#axis.text.x = element_blank(),
# axis.ticks.x = element_blank(),
axis.line = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(color = "gray60", size = 0.8, linetype = "dashed")
) +
coord_flip() +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 60000),
breaks = c(0, 1000, 5000, 10000, 50000)) # +
# geom_text(aes(label = formatC(Number, format = 'f', digits =2)),
# position= position_dodge(width=1), hjust =-.2, size=3)
) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- Most Private Foundations are classified under "Other social and health benefits"
- Higher Education and Healthcare facilities are two categories that had the smallest number of PFs in 2019.
- Overall, the category chart is consistent with what we are seeing in the 2019 PC Size-by-Category plot
### PF Finance Information by Category
```{r}
p19_category <- pf19_category %>%
# mutate(NTEEGRP = factor(NTEEGRP)) %>%
mutate(NTEEGRP = reorder(factor(NTEEGRP), Number)) %>%
filter(NTEEGRP != "Other public and social benefit") %>%
select(!c(2,4)) %>%
pivot_longer(2:3,
values_to = "Amount",
names_to = "Finance") %>%
ggplot(aes(y = Amount,
x = NTEEGRP,
fill = Finance))+
geom_bar(position = "dodge",
stat="identity",
width = .9) +
labs(x = "",
y = "") +
theme(
axis.line = element_blank(),
# axis.text.x = element_blank(),
# axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(color = "gray60", size = 0.8,
linetype = "dashed")
# panel.grid.major.x = element_blank(),
# panel.grid.minor.x = element_blank()
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 6),
breaks = c(0, 0.5, seq(1,6,1))) +
coord_flip() +
# geom_text(aes(label = Amount),
# position= position_dodge(width=1), hjust =-.1, size=3) +
# scale_x_discrete(limits = rev) +
theme(legend.position="right",
legend.direction = "vertical")
#%>%
# layout(legend = list(orientation = "h", x = 0.15, y = -0.1))
ggplotly(p19_category) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
***
- Human services, other healthcare, and other education-related Private Foundations had higher spendings and earnings than PFs in other groups
- Higher educations and hospitals-related Private Foundatios earned and spent the least compared to other typed PFs (because of their small numbers)
- Note: Category "Other public and social benefits" are excluded due to its extraordinarily large number
Volunteering and Giving
=======================================================================
Column {.tabset data-width=500}
-----------------------------------------------------------------------
### Volunteer Activities
```{r}
volunteer_act <-
read_csv("../Data/External_Data/NSiB_Figure4_Table.csv") %>%
select(!1)
```
```{r}
ggplotly(
volunteer_act %>%
filter(type != "Total") %>%
#filter(type != "Security procedures") %>% #Filtered out because equals 0%
ggplot(aes(x=reorder(type, -AsPct),
y =AsPct)) +
geom_bar(stat = "identity",
fill = "#BF87B3") +
scale_y_continuous(expand = c(0, 0),
limits = c(0,30)) +
labs(y = "Percent of total volunteer time") +
theme(#axis.text.y = element_blank(),
axis.title = element_blank(),
axis.ticks.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank()
) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 26),
breaks = c(0,1,5,10,20, 25)) +
scale_x_discrete(labels = function(type) str_wrap(type, width=10))
) %>% layout(hoverlabel = list(bgcolor = "white"))
```
### Value of Volunteering
```{r}
volunteer_val <- read_csv("../Data/External_Data/Volunteering Data.csv")
names(volunteer_val)[1] = ""
for (i in 1:15) { # change NA to ""
for (j in 2:11) {
if (i %in% c(1, 7, 11)) {
volunteer_val[i,j] <- ""
}
}
}
#reactable::reactable(volunteer_val)
#datatable(volunteer_val, extensions = c('FixedHeader'),rownames = FALSE ,
# options = list(dom='Bfrtip',autoWidth = TRUE, pageLength=15, buttons=c('print', #'csv', 'pdf'), fixedHeader =TRUE)) %>%
#formatStyle(NA, color = 'black', fontWeight = 'bold')
kable(volunteer_val,
"html",
format.args = list(decimal.mark = '.',
big.mark = ","),
align = "lcccccccccc",
col.names =
c("", "2008", "2009", "2010", "2011", "2012", "2013",
"2014", "2015", "2016", "2017")) %>%
kable_styling("hover",
full_width = F) %>%
row_spec(c(1,7,11),
bold = T,
hline_after = T )
```
Column {.tabset data-width=500}
-----------------------------------------------------------------------
### Giving Amount
```{r}
giving <-
read_csv("../Data/External_Data/NSiB_Figure2_Table.csv") %>%
select(!1)
```
```{r}
ggplotly(
giving %>%
filter(Year >2008) %>%
ggplot(aes(x=Year,
y =value,
fill = Contributions)) +
geom_bar(position = "dodge",
stat = "identity") +
scale_y_continuous(expand = c(0, 0),
limits = c(0,460),
breaks = seq(200,450,50)) +
scale_x_continuous(breaks = 2008:2018)+
theme(axis.line = element_blank(),
# axis.text.x = element_blank(),
# axis.ticks.y = element_blank(),
axis.ticks.x = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_line(color = "gray60",
size = 0.8,
linetype = "dashed")
) +
labs(x = "",
y = "") +
coord_flip() #+
# theme(legend.position="right", legend.direction = "vertical")
) %>%
layout(legend = list(orientation = "h",
x = 0.12,
y = -0.1),
hoverlabel = list(bgcolor = "white"))
```
### Giving by Charity Type
```{r}
giving_charity <-
read_csv("../Data/External_Data/NSiB_Table5.csv",
locale=locale(encoding="latin1")) %>%
select(!1)
names(giving_charity)[4] <- "%point changes"
giving_charity[3,4] = 0.2
giving_charity[5,4] = 0.3
giving_charity[7,4] = 0.3
```
```{r}
datatable(giving_charity,
extensions = c('FixedHeader'),
rownames = FALSE ,
options = list(dom='Bfrtip',
autoWidth = TRUE,
pageLength=15,
buttons=c('print', 'csv', 'pdf'),
fixedHeader =TRUE))
```
### Total Grants
```{r}
grant <-
read_csv("../Data/External_Data/NSiB_Figure3_Table.csv") %>%
select(!1)
```
```{r}
ggplotly(
grant %>%
ggplot(aes(x=Year,
y = Constant_Grants)) +
geom_bar(stat = "identity",
fill = "indianred") +
scale_y_continuous(expand = c(0, 0),
limits = c(0,85),
breaks = c(0, 40, 50, 60, 70, 80)) +
scale_x_continuous(breaks = 2005:2017)+
labs(#caption = "The Foundation Center, Foundation Stats (2019)",
x = "Year",
y = "Grants made (billions)" ) +
labs(x = "") +
theme(#axis.text.y = element_blank(),
# axis.line = element_blank(),
axis.ticks.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank()
) ) %>%
layout(hoverlabel = list(bgcolor = "white"))
```
Density Map
=======================================================================
Column {data-width=500}
-----------------------------------------------------------------------
### 2019 All 501c(3) Nonprofits
```{r, echo=FALSE}
size_map <-
geojsonio::geojson_read(
"../Data/Output_Data/nonprofit2019_size_map.geojson",
what = "sp")
pal <- colorBin( "RdPu", #do a space to enhance readability
domain = size_map$count,
bins = c(0, 9680, 17300, 33400, 47100, 180000),
na.color=NA )
# leaf.label <- paste0() # put the label format string here
labels <-
sprintf(
"%s
Number of Nonprofits: %1.0f
State Population in 2015: %1.0f",
size_map$name,
size_map$count,
size_map$pop_2015
) %>%
lapply(htmltools::HTML)
```
```{r}
leaflet(size_map) %>% # density: per 100,000
setView(-96, 37.8, 4) %>%
addProviderTiles("MapBox",
options = providerTileOptions(
id = "mapbox.light",
accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN'))) %>%
addPolygons(
fillColor = ~pal(count),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlightOptions = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal",
padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pal,
values = ~count,
opacity = 0.7,
title = "501c(3) Nonprofits in 2019",
position = "bottomright")
```
Column {.tabset data-width=500}
-----------------------------------------------------------------------
### 2019 Public Charities
```{r}
pc19_size_map <-
geojsonio::geojson_read(
"../Data/Output_Data/pc_nonprofit2019_size_map.geojson",
what = "sp")
pc_pal <- colorBin("BuGn",
domain = pc19_size_map$count,
bins = c(0, 2340, 4460, 7830, 12200, 53000),
na.color=NA)
pc_labels <-
sprintf(
"%s
Number of Nonprofits: %1.0f
State Population in 2015: %1.0f",
pc19_size_map$name,
pc19_size_map$count,
pc19_size_map$pop_2015) %>%
lapply(htmltools::HTML)
```
```{r}
leaflet(pc19_size_map) %>%
setView(-96, 37.8, 4) %>%
addProviderTiles("MapBox",
options = providerTileOptions(
id = "mapbox.light",
accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN'))) %>%
addPolygons(
fillColor = ~pc_pal(count),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlightOptions = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = pc_labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal",
padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pc_pal,
values = ~count,
opacity = 0.7,
title = "Public Charity in 2019",
position = "bottomright")
```
### 2019 Private Foundations
```{r}
pf19_size_map <-
geojsonio::geojson_read(
"../Data/Output_Data/pf_nonprofit2019_size_map.geojson",
what = "sp")
pf_pal <- colorBin("BuPu",
domain = pf19_size_map$count,
bins = c(0, 312, 633, 1100, 1850, 8400),
na.color=NA)
pf_labels <- sprintf(
"%s
Number of Nonprofits: %1.0f
State Population in 2015: %1.0f",
pf19_size_map$name,
pf19_size_map$count,
pf19_size_map$pop_2015) %>%
lapply(htmltools::HTML)
```
```{r}
leaflet(pf19_size_map) %>%
setView(-96, 37.8, 4) %>%
addProviderTiles("MapBox",
options = providerTileOptions(
id = "mapbox.light",
accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN'))) %>%
addPolygons(
fillColor = ~pf_pal(count),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlightOptions = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = pf_labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal",
padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pf_pal,
values = ~count,
opacity = 0.7,
title = "Private Foundation in 2019",
position = "bottomright")
```